export function mymap(ak) {
  return new Promise(function(resolve, reject) {
    window.init = function() {
      resolve(mymap)
    }
    var script = document.createElement('script')
    script.type = 'text/javascript'    
    script.src = `http://api.map.baidu.com/api?v=2.0&ak=SENtUxANhrGmz5Kpi7bj7uZbbMNRI9RS`	
    script.onerror = reject
    document.head.appendChild(script)
  })
}
/**检查是否打开GPS功能（android）**/
export function checkOpenGPSServiceByAndroid(){
  let system = uni.getSystemInfoSync();// 获取系统信息
  if (system.platform === 'android') { // 判断平台
    var context = plus.android.importClass("android.content.Context");
    var locationManager = plus.android.importClass("android.location.LocationManager");
    var main = plus.android.runtimeMainActivity();
    var mainSvr = main.getSystemService(context.LOCATION_SERVICE);
    if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
      uni.showModal({
        title: '提示',
        content: '请打开定位服务功能',
        showCancel: false, // 不显示取消按钮
        success() {
          if (!mainSvr.isProviderEnabled(locationManager.GPS_PROVIDER)) {
            var Intent = plus.android.importClass('android.content.Intent');
            var Settings = plus.android.importClass('android.provider.Settings');
            var intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); 
            main.startActivity(intent); // 打开系统设置GPS服务页面
          } else {
            console.log('GPS功能已开启');
          }
        }
      });
    }
  } 
}